package com.github.wui.RulerView;


import android.annotation.SuppressLint;
import android.content.Context;
import android.content.res.TypedArray;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Matrix;
import android.graphics.Paint;
import android.graphics.Point;
import android.graphics.RectF;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.util.Log;
import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.github.wui.R;

import java.util.ArrayList;
import java.util.List;

/**
 * 定制化 尺子控件开发
 *
 * @author Mr.xie
 * @Date 2025/5/8
 */
public class RulerView extends View {


    /**
     * 刻度画笔
     */
//    private Paint scalePaint = null;


    /**
     * 刻度颜色
     */
    private int scaleColor = Color.WHITE;


    /**
     * 刻度文字画笔
     */
    private Paint scaleTextPaint = null;


    /**
     * 刻度文字颜色
     */

    private int scaleTextColor = Color.WHITE;


    /**
     * 右边刻度最小间距
     */
    private int rightScaleMinSpace = 160;

    /**
     * 右边 大刻度的等分
     */
    private int rightScaleDividePart = 10;


    /**
     * 右边的 最大刻度值
     */
    private int rightScaleMaxNums = 0;


    /**
     * 右边大刻度的坐标集
     */
    private List<Point> rightScalePoint = new ArrayList<>();


    /**
     * 左边刻度最小间距
     */
    private int leftScaleMinSpace = 300;

    /**
     * 左边大刻度的等分
     */
    private float leftScaleDividePart = 10;


    /**
     * 左边的 最大刻度值
     */
    private int leftScaleMaxNums = 0;


    /**
     * 左边大刻度的坐标集
     */
    private List<Point> leftScalePoint = new ArrayList<>();


    /**
     * 刻度线的画笔
     */
    private Paint rulerLinePaint = null;


    /**
     * 刻度线的颜色
     */
    private int rulerLineColor = Color.WHITE;


    /**
     * 选中区域上边边界线
     */
    private Paint topFrameBorderLinePaint = null;

    /**
     * 宣红区域上边边界线的颜色
     */
    private int topFrameBorderLineColor = Color.parseColor("#c1db5a");


    private int topFrameBorderLineWidth = 10;

    /**
     * 选中区域上边边界线的坐标
     */
    private Point[] topFrameBorderLinePoint = null;


    /**
     * 选中区域下边边界线
     */
    private Paint bottomFrameBorderLinePaint = null;

    private int bottomFrameBorderLineWidth = 10;

    /**
     * 选中区域下边边界线的颜色
     */
    private int bottomFrameBorderLineColor = Color.parseColor("#c1db5a");


    /**
     * 选中区域下边边界线的坐标
     */
    private Point[] bottomFrameBorderLinePoint = null;


    /**
     * 调整顶部距离的参数
     */
    private int configTopSpace = 30;


    /**
     * 默认移动距离
     */
    private int move_distance = 20;

    /**
     * 当前触摸的拿一根线 0 上边界  1 下边界
     */
    private int lineNum = 1;


    /**
     * 记录前一个选中的线的编号 0 是上边界 1 下边界 -1 没有选中
     */
    int preLine = lineNum;

    /**
     * 标志手指是否离开屏幕 离开了 就设置选中 linenum = -1； 一遍后续重新选择边框线
     */
    boolean isUp = true;


    private boolean isEnable = false;


    /**
     * 刻度文字字体大小
     */
    private float scaleTextSize = 25f;


    /**
     * 显示文字的画笔
     */
    private Paint textPaint = null;


    /**
     * 显示文字的颜色
     */
    private int textColor = Color.WHITE;


    /**
     * 显示文字的大小
     */
    private float textSize = 15f;


    private String rightScaleUnit = "单位";


    private String leftScaleUnit = "单位";


    private int leftScaleTextToLineSpace = 3;

    private int rightScaleTextToLineSpace = 3;


    private float showTextGap = 20f;


    private int textPriority = 0;

    private int lineTouchEnableAreaDistance = 20;

    private int maxBorderLineLimit = 40;


    private Paint selectedAreaPaint = null;


    /**
     * 选中区域的颜色
     */
    private int selectedAreaColor = Color.GREEN;


    public RulerView(Context context) {
        this(context, null);
    }

    public RulerView(Context context, @Nullable AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public RulerView(Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
        super(context, attrs, defStyleAttr);
        TypedArray typedArray = context.obtainStyledAttributes(attrs, R.styleable.RulerView);

        this.scaleTextColor = typedArray.getColor(R.styleable.RulerView_scaleTextColor, Color.BLACK);
        this.scaleTextSize = typedArray.getDimension(R.styleable.RulerView_scaleTextSize, 25f);
        this.rightScaleMinSpace = typedArray.getInteger(R.styleable.RulerView_rightScaleMinSpace, 160);
        this.leftScaleMinSpace = typedArray.getInteger(R.styleable.RulerView_leftScaleMinSpace, 300);
        this.rightScaleDividePart = typedArray.getInteger(R.styleable.RulerView_rightScaleDividePart, 10);
        this.leftScaleDividePart = typedArray.getInteger(R.styleable.RulerView_rightScaleDividePart, 10);
        this.rulerLineColor = typedArray.getColor(R.styleable.RulerView_rulerLineColor, Color.BLACK);
        this.topFrameBorderLineColor = typedArray.getColor(R.styleable.RulerView_topFrameBorderLineColor, Color.BLACK);
        this.bottomFrameBorderLineColor = typedArray.getColor(R.styleable.RulerView_bottomFrameBorderLineColor, Color.BLACK);
        this.topFrameBorderLineWidth = typedArray.getInteger(R.styleable.RulerView_topFrameBorderLineWidth, 3);
        this.bottomFrameBorderLineWidth = typedArray.getInteger(R.styleable.RulerView_bottomFrameBorderLineWidth, 3);
        this.configTopSpace = typedArray.getInteger(R.styleable.RulerView_configTopSpace, 30);
        this.textColor = typedArray.getColor(R.styleable.RulerView_textColor, Color.WHITE);
        this.selectedAreaColor = typedArray.getColor(R.styleable.RulerView_selectedAreaColor, Color.alpha(Color.BLUE));
        this.textSize = typedArray.getDimension(R.styleable.RulerView_textSize, 15f);
        this.rightScaleUnit = typedArray.getString(R.styleable.RulerView_rightScaleUnit);
        this.leftScaleUnit = typedArray.getString(R.styleable.RulerView_leftScaleUnit);
        this.rightScaleTextToLineSpace = typedArray.getInteger(R.styleable.RulerView_rightScaleTextToLineSpace, 3);
        this.leftScaleTextToLineSpace = typedArray.getInteger(R.styleable.RulerView_leftScaleTextToLineSpace, 3);
        this.showTextGap = typedArray.getDimension(R.styleable.RulerView_showTextGap, 10f);
        this.textPriority = typedArray.getInteger(R.styleable.RulerView_textPriority, 0);
        this.lineTouchEnableAreaDistance = typedArray.getInteger(R.styleable.RulerView_lineTouchEnableAreaDistance, getMeasuredWidth() / 3);
        this.maxBorderLineLimit = typedArray.getInteger(R.styleable.RulerView_maxBorderLineLimit, 40);
        typedArray.recycle();
        init();
    }

    private int calculateScaleParams(int minScaleSpace, int dividePart) {
        return Math.round((float) getMeasuredHeight() / minScaleSpace);
    }


    /**
     * 属性初始化
     */
    private void init() {
        this.textPaint = new Paint();
        this.textPaint.setAntiAlias(true);
        this.textPaint.setColor(textColor);
        this.textPaint.setTextSize(textSize);


        this.scaleTextPaint = new Paint();
        this.scaleTextPaint.setAntiAlias(true);
        this.scaleTextPaint.setColor(scaleTextColor);
        this.scaleTextPaint.setTextSize(scaleTextSize);
        this.scaleTextPaint.setLinearText(true);


        this.rulerLinePaint = new Paint();
        this.rulerLinePaint.setAntiAlias(true);
        this.rulerLinePaint.setColor(rulerLineColor);

        // 选中边框画笔初始化
        this.topFrameBorderLinePaint = new Paint();
        this.topFrameBorderLinePaint.setAntiAlias(true);
        this.topFrameBorderLinePaint.setStrokeWidth(this.topFrameBorderLineWidth);
        this.topFrameBorderLinePaint.setColor(topFrameBorderLineColor);


        this.bottomFrameBorderLinePaint = new Paint();
        this.bottomFrameBorderLinePaint.setAntiAlias(true);
        this.bottomFrameBorderLinePaint.setStrokeWidth(this.bottomFrameBorderLineWidth);
        this.bottomFrameBorderLinePaint.setColor(bottomFrameBorderLineColor);

        this.selectedAreaPaint = new Paint();
        this.selectedAreaPaint.setAntiAlias(true);
        this.selectedAreaPaint.setColor(this.selectedAreaColor);

    }


    @SuppressLint("DrawAllocation")
    @Override
    protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
        super.onMeasure(widthMeasureSpec, heightMeasureSpec);
        ViewGroup.MarginLayoutParams layoutParams = (ViewGroup.MarginLayoutParams) getLayoutParams();
        int mineWidth = layoutParams.width; // 我的宽度
        int mineHeight = layoutParams.height; // 我的高度

        // 如果是等于 wrapcontent  就默认撑满整个父容器
        if (mineWidth == ViewGroup.LayoutParams.WRAP_CONTENT || mineWidth == ViewGroup.LayoutParams.MATCH_PARENT) {
            mineWidth = MeasureSpec.getSize(widthMeasureSpec);
        }
        if (mineHeight == ViewGroup.LayoutParams.WRAP_CONTENT || mineHeight == ViewGroup.LayoutParams.MATCH_PARENT) {
            mineHeight = MeasureSpec.getSize(heightMeasureSpec);
        }


        // 如果是自己指定的高度 就设置为自己指定的宽高就行 然后根据宽高 自动去生成 尺子的
        setMeasuredDimension(mineWidth, mineHeight);

        this.rightScaleMaxNums = calculateScaleParams(rightScaleMinSpace, rightScaleDividePart);
        this.leftScaleMaxNums = calculateScaleParams(rightScaleMinSpace, rightScaleDividePart);
        initRightScalePoint(rightScaleMaxNums);
        initLeftScalePoint(leftScaleMaxNums);
        //初始化边框线的坐标 默认 两根线都是从顶部出发
        this.topFrameBorderLinePoint = new Point[]{new Point(0, (int) (configTopSpace + this.scaleTextPaint.getTextSize() / 3)), new Point(getMeasuredWidth(), (int) (configTopSpace + this.scaleTextPaint.getTextSize() / 3))};
        this.bottomFrameBorderLinePoint = new Point[]{new Point(0, (int) (configTopSpace + this.scaleTextPaint.getTextSize() / 3)), new Point(getMeasuredWidth(), (int) (configTopSpace + this.scaleTextPaint.getTextSize() / 3))};
        Log.e("TAG", "onMeasure: " + rightScaleMaxNums);
    }


    private void initRightScalePoint(int rightScaleMaxNums) {
        rightScalePoint.clear();
        for (int i = 0; i < rightScaleMaxNums; i++) {
            rightScalePoint.add(new Point(getMeasuredWidth(), i * rightScaleMinSpace + configTopSpace));
        }

        Log.e("TAG", "initRightScalePoint: " + rightScalePoint);
    }

    private void initLeftScalePoint(int leftScaleMaxNums) {
        leftScalePoint.clear();
        for (int i = 0; i < leftScaleMaxNums; i++) {
            leftScalePoint.add(new Point(20, i * leftScaleMinSpace + configTopSpace)); // 30 调整刻度距离顶部距离
        }
    }


    @Override
    protected void onDraw(@NonNull Canvas canvas) {
        super.onDraw(canvas);

        initRightScale(canvas);
        initLeftScale(canvas);
        initFrame(canvas);
    }


    /**
     * 绘制frame  选中区域
     *
     * @param canvas 画布
     */
    private void initFrame(Canvas canvas) {

        drawBorderLine(canvas);

    }

    public void drawBorderLine(Canvas canvas) {

        if (topFrameBorderLinePoint[0].y <= 0 + configTopSpace) {
            topFrameBorderLinePoint[0].y = 0 + configTopSpace;
            topFrameBorderLinePoint[1].y = 0 + configTopSpace;
        }

        if (bottomFrameBorderLinePoint[0].y <= 0 + configTopSpace) {
            bottomFrameBorderLinePoint[0].y = 0 + configTopSpace;
            bottomFrameBorderLinePoint[1].y = 0 + configTopSpace;
        }

        if (topFrameBorderLinePoint[0].y >= getMeasuredHeight() - maxBorderLineLimit) {
            topFrameBorderLinePoint[0].y = getMeasuredHeight() - maxBorderLineLimit;
            topFrameBorderLinePoint[1].y = getMeasuredHeight() - maxBorderLineLimit;
        }

        if (bottomFrameBorderLinePoint[0].y >= getMeasuredHeight() - maxBorderLineLimit) {
            bottomFrameBorderLinePoint[0].y = getMeasuredHeight() - maxBorderLineLimit;
            bottomFrameBorderLinePoint[1].y = getMeasuredHeight() - maxBorderLineLimit;
        }
        RectF selectedRectF = new RectF();
        selectedRectF.top = topFrameBorderLinePoint[0].y;
        selectedRectF.bottom = bottomFrameBorderLinePoint[0].y;
        selectedRectF.right = 0;
        selectedRectF.left = getMeasuredWidth();

        if (this.textPriority == 0) {
            // 计算长度

            // 计算出右边 1mm 的长度

            // 1 + 140 / 160  1.87
            float rightLengthNum = ((float) (bottomFrameBorderLinePoint[0].y - topFrameBorderLinePoint[0].y) / rightScaleMinSpace);
            float leftLengthNum = ((float) (bottomFrameBorderLinePoint[0].y - topFrameBorderLinePoint[0].y) / leftScaleMinSpace);

            drawResult(String.format("%.2f", Math.abs(rightLengthNum)) + this.rightScaleUnit, canvas, (int) (getMeasuredWidth() / 2 - showTextGap), getMeasuredHeight() / 2 - 10, 90);
            drawResult(String.format("%.2f", Math.abs(leftLengthNum)) + this.leftScaleUnit, canvas, (int) (getMeasuredWidth() / 2 - 40 + showTextGap), getMeasuredHeight() / 2 - 10, 90);


//            Log.e("TAG", "drawBorderLine: " + topFrameBorderLinePoint[0].y + " " + bottomFrameBorderLinePoint[0].y);
            canvas.drawLine(topFrameBorderLinePoint[0].x, topFrameBorderLinePoint[0].y, topFrameBorderLinePoint[1].x, topFrameBorderLinePoint[1].y, topFrameBorderLinePaint);
            canvas.drawLine(bottomFrameBorderLinePoint[0].x, bottomFrameBorderLinePoint[0].y, bottomFrameBorderLinePoint[1].x, bottomFrameBorderLinePoint[1].y, bottomFrameBorderLinePaint);
            canvas.drawRect(selectedRectF , this.selectedAreaPaint);
        } else if (this.textPriority == 1) {
            float rightLengthNum = ((float) (bottomFrameBorderLinePoint[0].y - topFrameBorderLinePoint[0].y) / rightScaleMinSpace);
            float leftLengthNum = ((float) (bottomFrameBorderLinePoint[0].y - topFrameBorderLinePoint[0].y) / leftScaleMinSpace);
            canvas.drawLine(topFrameBorderLinePoint[0].x, topFrameBorderLinePoint[0].y, topFrameBorderLinePoint[1].x, topFrameBorderLinePoint[1].y, topFrameBorderLinePaint);
            canvas.drawLine(bottomFrameBorderLinePoint[0].x, bottomFrameBorderLinePoint[0].y, bottomFrameBorderLinePoint[1].x, bottomFrameBorderLinePoint[1].y, bottomFrameBorderLinePaint);
            canvas.drawRect(selectedRectF , this.selectedAreaPaint);
            drawResult(String.format("%.2f", Math.abs(rightLengthNum)) + this.rightScaleUnit, canvas, (int) (getMeasuredWidth() / 2 - showTextGap), getMeasuredHeight() / 2 - 10, 90);
            drawResult(String.format("%.2f", Math.abs(leftLengthNum)) + this.leftScaleUnit, canvas, (int) (getMeasuredWidth() / 2 - 40 + showTextGap), getMeasuredHeight() / 2 - 10, 90);

        }


    }


    /**
     * 绘制右边刻度
     */
    public void initRightScale(Canvas canvas) {
        for (int i = 0; i < rightScalePoint.size(); i++) {
            Point rightScale = rightScalePoint.get(i);
            int x = (int) (getMeasuredWidth() - this.scaleTextPaint.getTextSize() - 40);
            drawLayNumber(String.valueOf(i), canvas, x - this.rightScaleTextToLineSpace, rightScale.y);
            canvas.drawLine(x + this.scaleTextPaint.getTextSize(), rightScale.y + (this.scaleTextPaint.getTextSize() / 3 * String.valueOf(i).length()), getMeasuredWidth(), rightScale.y + (this.scaleTextPaint.getTextSize() / 3 * String.valueOf(i).length()), this.rulerLinePaint);

            // 绘制小刻度
            for (int smallScale_i = i * rightScaleDividePart; smallScale_i < (i + 1) * rightScaleDividePart; smallScale_i++) {
                int smallScaleY = (smallScale_i) * (rightScaleMinSpace / rightScaleDividePart) + configTopSpace;
                Log.e("TAG", "smallScaleY: " + smallScaleY);
                canvas.drawLine(x + this.scaleTextPaint.getTextSize() + (smallScale_i % 5 != 0 ? 10 : 2), smallScaleY + (this.scaleTextPaint.getTextSize() / 3 * String.valueOf(i).length()),  // 30 用来调节刻度
                        getMeasuredWidth(), smallScaleY + (this.scaleTextPaint.getTextSize() / 3 * String.valueOf(i).length()), this.rulerLinePaint);
            }

        }
    }


    public void initLeftScale(Canvas canvas) {
        for (int i = 0; i < leftScalePoint.size(); i++) {
            Point rightScale = leftScalePoint.get(i);
            drawLayNumber(String.valueOf(i), canvas, rightScale.x + 20 + this.leftScaleTextToLineSpace, rightScale.y);


            // 10 是调节参数
            canvas.drawLine(0,
                    rightScale.y + (this.scaleTextPaint.getTextSize() / 3 * String.valueOf(i).length()),
                    rightScale.x + this.scaleTextPaint.getTextSize() - 10,
                    rightScale.y + (this.scaleTextPaint.getTextSize() / 3 * String.valueOf(i).length()), this.rulerLinePaint);

            // 绘制小刻度
            for (int smallScale_i = (int) (i * leftScaleDividePart); smallScale_i < (i + 1) * leftScaleDividePart; smallScale_i++) {
                int smallScaleY = (int) ((smallScale_i) * (leftScaleMinSpace / leftScaleDividePart) + configTopSpace);
                Log.e("TAG", "smallScaleY: " + smallScaleY);
                float v = this.scaleTextPaint.getTextSize() / 3 * String.valueOf(i).length();
                canvas.drawLine(0, smallScaleY + v,  // 30 用来调节刻度
                        rightScale.x + this.scaleTextPaint.getTextSize() - 10 - (smallScale_i % 5 != 0 ? 10 : 2), smallScaleY + v, this.rulerLinePaint);
            }

        }
    }


    public void drawLayNumber(String text, Canvas canvas, int x, int y) {
        Matrix matrix = new Matrix();
        float pivotX = x;
        float pivotY = y;
        matrix.postRotate(90, pivotX, pivotY);
        canvas.save();
        canvas.concat(matrix);
        canvas.drawText(text, x, y, scaleTextPaint);
        canvas.restore(); // 恢复画布状态
    }


    public void drawResult(String text, Canvas canvas, int x, int y, float deg) {
        Matrix matrix = new Matrix();
        float pivotX = x;
        float pivotY = y;
        matrix.postRotate(deg, pivotX, pivotY);
        canvas.save();
        canvas.concat(matrix);
        canvas.drawText(text, x, y, this.textPaint);
        canvas.restore(); // 恢复画布状态
    }

    float startY = 0;

    @Override
    public boolean onTouchEvent(MotionEvent event) {
        isEnable = checkTouchLine(event.getX(), event.getY());
        switch (event.getAction()) {
            case MotionEvent.ACTION_DOWN:
                startY = event.getY();
                float startX = event.getX();
                checkTouchLine(startX, startY);
                isUp = false;
                break;
            case MotionEvent.ACTION_MOVE:
                float endY = event.getY();
                if (endY - startY < 0) {
                    // 上移动
                    if (lineNum == 1) {
                        bottomFrameBorderLinePoint[0].y = (int) endY;
                        bottomFrameBorderLinePoint[1].y = (int) endY;
                    } else if (lineNum == 0) {
                        topFrameBorderLinePoint[0].y = (int) endY;
                        topFrameBorderLinePoint[1].y = (int) endY;
                    }

                } else if (endY - startY > 0) {
                    if (lineNum == 1) {
                        bottomFrameBorderLinePoint[0].y = (int) endY;
                        bottomFrameBorderLinePoint[1].y = (int) endY;
                    } else if (lineNum == 0) {
                        topFrameBorderLinePoint[0].y = (int) endY;
                        topFrameBorderLinePoint[1].y = (int) endY;
                    }
                }


                invalidate();

                break;
            case MotionEvent.ACTION_UP:
                isUp = true;
                lineNum = -1;
                break;
        }

        return true;

    }


    private boolean checkTouchLine(float endX, float endY) {

        if (checkLineIsComment()) {
            if (!isUp) {
                lineNum = preLine;
            } else {
                lineNum = 1;
                preLine = lineNum;
            }
            return true;
        }
        if (endY > bottomFrameBorderLinePoint[0].y - lineTouchEnableAreaDistance && endY < bottomFrameBorderLinePoint[0].y + lineTouchEnableAreaDistance && (endX >= bottomFrameBorderLinePoint[0].x && endX <= bottomFrameBorderLinePoint[1].x)) {
            if (!isUp) {
                lineNum = preLine;
            } else {
                lineNum = 1;
                preLine = lineNum;
            }
            return true;
        }

        if (endY > topFrameBorderLinePoint[0].y - lineTouchEnableAreaDistance && endY < topFrameBorderLinePoint[0].y + lineTouchEnableAreaDistance && (endX >= topFrameBorderLinePoint[0].x && endX <= topFrameBorderLinePoint[1].x)) {
            if (!isUp) {
                lineNum = preLine;
            } else {
                lineNum = 0;
                preLine = lineNum;
            }
            return true;
        }

        lineNum = -1;
        preLine = -1;
        isUp = true;

        return false;
    }


    /**
     * 检查两根线是否已经重合
     *
     * @return true 重合了
     */
    public boolean checkLineIsComment() {
        boolean isComment = false;
        for (int i = 0; i < topFrameBorderLinePoint.length; i++) {
            if (topFrameBorderLinePoint[i].x == bottomFrameBorderLinePoint[i].x && topFrameBorderLinePoint[i].y == bottomFrameBorderLinePoint[i].y) {
                isComment = true;
            }
        }
        return isComment;
    }


    public static int cmToPx(Context context, float cm) {
        DisplayMetrics metrics = context.getResources().getDisplayMetrics();
        float dpi = metrics.densityDpi; // 屏幕密度（DPI）
        float px = cm * dpi / 2.54f;
        return (int) px;
    }


    public int getScaleColor() {
        return scaleColor;
    }

    public void setScaleColor(int scaleColor) {
        this.scaleColor = scaleColor;
    }

    public int getScaleTextColor() {
        return scaleTextColor;

    }

    public void setScaleTextColor(int scaleTextColor) {
        this.scaleTextColor = scaleTextColor;

    }

    public int getRightScaleMinSpace() {
        return rightScaleMinSpace;
    }

    public void setRightScaleMinSpace(int rightScaleMinSpace) {
        this.rightScaleMinSpace = rightScaleMinSpace;
    }

    public int getRightScaleDividePart() {
        return rightScaleDividePart;
    }

    public void setRightScaleDividePart(int rightScaleDividePart) {
        this.rightScaleDividePart = rightScaleDividePart;
    }

    public int getRightScaleMaxNums() {
        return rightScaleMaxNums;
    }

    public void setRightScaleMaxNums(int rightScaleMaxNums) {
        this.rightScaleMaxNums = rightScaleMaxNums;
    }

    public int getLeftScaleMinSpace() {
        return leftScaleMinSpace;
    }

    public void setLeftScaleMinSpace(int leftScaleMinSpace) {
        this.leftScaleMinSpace = leftScaleMinSpace;
    }

    public float getLeftScaleDividePart() {
        return leftScaleDividePart;
    }

    public void setLeftScaleDividePart(int leftScaleDividePart) {
        this.leftScaleDividePart = leftScaleDividePart;
    }

    public int getLeftScaleMaxNums() {
        return leftScaleMaxNums;
    }

    public void setLeftScaleMaxNums(int leftScaleMaxNums) {
        this.leftScaleMaxNums = leftScaleMaxNums;
    }

    public int getRulerLineColor() {
        return rulerLineColor;
    }

    public void setRulerLineColor(int rulerLineColor) {
        this.rulerLineColor = rulerLineColor;
    }

    public int getTopFrameBorderLineColor() {
        return topFrameBorderLineColor;
    }

    public void setTopFrameBorderLineColor(int topFrameBorderLineColor) {
        this.topFrameBorderLineColor = topFrameBorderLineColor;
    }

    public int getBottomFrameBorderLineColor() {
        return bottomFrameBorderLineColor;
    }

    public void setBottomFrameBorderLineColor(int bottomFrameBorderLineColor) {
        this.bottomFrameBorderLineColor = bottomFrameBorderLineColor;
    }

    public int getConfigTopSpace() {
        return configTopSpace;
    }

    public void setConfigTopSpace(int configTopSpace) {
        this.configTopSpace = configTopSpace;
    }

    public boolean isUp() {
        return isUp;
    }

    public void setUp(boolean up) {
        isUp = up;
    }
}


